package com.rd.student.jiaji.class3.sunguowei.Questions;

import java.util.*;

public class seven {
    public static void main(String[] args) {
        String str="哈尔滨,大庆,绥化,齐齐哈尔,杭州,宁波,南昌,广州,福州,厦门";
        String[] str1=str.split(",");
//        System.out.println(Arrays.toString(str1));

        String str11="黑龙江省,黑龙江省,黑龙江省,黑龙江省,浙江省,浙江省,江西省,广东省,福建省,福建省";
        String[] str2=str11.split(",");
        HashMap hashMap=new HashMap();


        HashSet set=new HashSet();
        for (int i = 0; i < str2.length; i++) {
            set.add(str2[i]);
            String value=str2[i];
            String key=str1[i];
            hashMap.put(key,value);
        }
        //        public static void info(HashMap hashMap){
//            Set set = hashMap.keySet();
//            Iterator iterator = set.iterator();
//            while (iterator.hasNext()) {
//                Object key = iterator.next();
//                Object value = hashMap.get(key);
//                System.out.println("<" + key + "," + value + ">");
//            }
//        }


        System.out.println(hashMap);
        System.out.println(set);
        System.out.println("-----------------");
        HashMap hashMap1=countNum(str2);
        System.out.println(hashMap1);



    }
    public static HashMap countNum(String[] str2){
        HashMap hashMap1=new HashMap();
        for (int i = 0; i < str2.length; i++) {
//        HashSet set1=new HashSet();
//        set1.add(str2[i]);
            String key= str2[i];
//                hashMap1.put(key,value);
            if(!hashMap1.containsKey(key)){
                hashMap1.put(key,1);
            }else{

                int value=(Integer) hashMap1.get(key);
                hashMap1.put(key,value+1);
            }

        }

        return hashMap1;
    }



}